using CodePlex.TfsLibrary.ClientEngine;
using CodePlex.TfsLibrary.ObjectModel;
using CodePlex.TfsLibrary.RepositoryWebSvc;

namespace CodePlex.CodePlexClientLibrary
{
    public class ListViewPresenter
    {
        readonly ITfsEngine engine;
        readonly IListView view;

        public ListViewPresenter(IListView view,
                                 ITfsEngine engine)
        {
            this.view = view;
            this.engine = engine;
        }

        public void Run(string tfsUrl,
                        string serverPath,
                        bool recursive,
                        VersionSpec version)
        {
            engine.List(tfsUrl, serverPath, recursive, version,
                        delegate(SourceItem item,
                                 SourceItemResult result)
                        {
                            view.DisplayItem(item, result);
                        });
        }
    }
}